package com.ts.api.module.product.entity.qo;

import com.ts.api.common.constant.productflow.ProductApplyFlowStatusEnum;
import lombok.Data;

import java.util.List;

/**
 *  机构进件流程表查询实体
 *
 *  @author Pan
 */
@Data
public class ProductApplyFlowQO {

    /** 渠道id */
    private Long loanChannelId;
    /** 主体id */
    private Long productId;
    /** 主体计划id */
    private Long productPlanId;
    /** api客户端主键id */
    private String apiClientId;
    /** 手机号码md5 */
    private String phoneMd5;
    /** 当前业务状态(1=撞库成功, 2=对方已进件, 3=用户已进入回调页面, 4=用户已点击协议) */
    private Integer status;
    /** 查询状态集合 */
    private List<Integer> statusList;
    /** 0测试环境 1正式环境 */
    private Integer apiEnvType;
    /** 请求id */
    private String reqId;
    /** 起始时间 */
    private String startTime;
    /** 结束时间 */
    private String endTime;

    /**
     * 创建实体，根据phoneMd5
     * 默认业务状态为撞库成功的
     *
     * @param  phoneMd5
     * @return ProductApplyFlowQO
     */
    public static ProductApplyFlowQO createByPhoneMd5(String phoneMd5) {
        ProductApplyFlowQO qo = new ProductApplyFlowQO();
        qo.setPhoneMd5(phoneMd5);
        return qo;
    }

    /**
     *  创建实体，根据phoneMd
     *  默认业务状态为撞库成功的
     *
     * @param  phoneMd5
     * @param  loanChannelId
     * @return ProductApplyFlowQO
     */
    public static ProductApplyFlowQO createBySucDataExchange(String phoneMd5, Long loanChannelId) {
        ProductApplyFlowQO qo = new ProductApplyFlowQO();
        qo.setPhoneMd5(phoneMd5);
        qo.setLoanChannelId(loanChannelId);
        qo.setStatus(ProductApplyFlowStatusEnum.DATA_EXCHANGE_SUC.getType());
        return qo;
    }

    /**
     * 创建H5回调专用
     * 默认业务状态为撞库成功的
     *
     * @param  phoneMd5
     * @return ProductApplyFlowQO
     */
    public static ProductApplyFlowQO createH5Callback(String phoneMd5, String apiClientId) {
        ProductApplyFlowQO productApplyFlowQO = new ProductApplyFlowQO();
        productApplyFlowQO.setStatus(ProductApplyFlowStatusEnum.CHANNEL_DATA_EXCHANGE.getType());
        productApplyFlowQO.setPhoneMd5(phoneMd5);
        productApplyFlowQO.setApiClientId(apiClientId);
        return productApplyFlowQO;
    }

    /**
     *  创建半流程回调通知流程
     *  默认业务状态为撞库成功的
     *
     *  @param  productId       主体管理id
     *  @param  productPlanId   主体计划id
     *  @param  phoneMd5        手机号MD5
     *  @return ProductApplyFlowQO
     */
    public static ProductApplyFlowQO createNoticeCallback(Long productId, Long productPlanId,String phoneMd5) {
        ProductApplyFlowQO productApplyFlowQO = new ProductApplyFlowQO();
        productApplyFlowQO.setStatus(ProductApplyFlowStatusEnum.CHANNEL_DATA_EXCHANGE.getType());
        productApplyFlowQO.setPhoneMd5(phoneMd5);
        productApplyFlowQO.setProductId(productId);
        productApplyFlowQO.setProductPlanId(productPlanId);
        return productApplyFlowQO;
    }

    /**
     * 创建H5回调专用
     * 自定义业务状态
     *
     * @param  phoneMd5
     * @return ProductApplyFlowQO
     */
    public static ProductApplyFlowQO createCustomFlowByPhoneMd5(String phoneMd5, ProductApplyFlowStatusEnum productApplyFlowStatusEnum) {
        ProductApplyFlowQO productApplyFlowQO = new ProductApplyFlowQO();
        productApplyFlowQO.setStatus(productApplyFlowStatusEnum.getType());
        productApplyFlowQO.setPhoneMd5(phoneMd5);
        return productApplyFlowQO;
    }
}
